<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Closure 类</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="serializable.unserialize.html">Serializable::unserialize</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="closure.construct.html">Closure::__construct</a></div>
 <div class="up"><a href="reserved.interfaces.html">预定义接口</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="class.closure" class="reference">

 <h1 class="title">Closure 类</h1>
 

 <div class="partintro"><p class="verinfo">(PHP 5 &gt;= 5.3.0)</p>


  <div class="section" id="closure.intro">
   <h2 class="title">简介</h2>
   <p class="para">
    用于代表 <a href="functions.anonymous.html" class="link">匿名函数</a>
    的类.
   </p>

   <p class="para">
    匿名函数（在 PHP 5.3 中被引入）会产生这个类型的对象。在过去，这个类被认为是一个实现细节，但现在可以依赖它做一些事情。自
    PHP 5.4 起，这个类带有一些方法，允许在匿名函数创建后对其进行更多的控制。
   </p>

   <p class="para">
    除了此处列出的方法，还有一个
    <em>__invoke</em> 方法。这是为了与其他实现了
    <a href="language.oop5.magic.html#language.oop5.magic.invoke" class="link">__invoke()魔术方法</a>
    的对象保持一致性，但调用匿名函数的过程与它无关。
   </p>

  </div>


  <div class="section" id="closure.synopsis">
   <h2 class="title">类摘要</h2>


   <div class="classsynopsis">
    <div class="ooclass"></div>


    <div class="classsynopsisinfo">
     <span class="ooclass">
      <strong class="classname">Closure</strong>
     </span>
     {</div>

    
    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 方法 */</div>
    <div class="methodsynopsis dc-description">
   <span class="methodname"><a href="closure.construct.html" class="methodname">__construct</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="modifier">static</span> <span class="type">Closure</span><span class="methodname"><a href="closure.bind.html" class="methodname">bind</a></span>
    ( <span class="methodparam"><span class="type"><a href="class.closure.html" class="type Closure">Closure</a></span> <code class="parameter">$closure</code></span>
   , <span class="methodparam"><span class="type">object</span> <code class="parameter">$newthis</code></span>
   [, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$newscope</code>
   <span class="initializer"> = &#039;static&#039;</span></span>
  ] )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">Closure</span><span class="methodname"><a href="closure.bindto.html" class="methodname">bindTo</a></span>
    ( <span class="methodparam"><span class="type">object</span> <code class="parameter">$newthis</code></span>
   [, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$newscope</code>
   <span class="initializer"> = &#039;static&#039;</span></span>
  ] )</div>

   }</div>


  </div>

 </div>

 








 



 





 









<h2>Table of Contents</h2><ul class="chunklist chunklist_reference"><li><a href="closure.construct.html">Closure::__construct</a> — 用于禁止实例化的构造函数</li><li><a href="closure.bind.html">Closure::bind</a> — 复制一个闭包，绑定指定的$this对象和类作用域。</li><li><a href="closure.bindto.html">Closure::bindTo</a> — 复制当前闭包对象，绑定指定的$this对象和类作用域。</li></ul>
</div>
<hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="serializable.unserialize.html">Serializable::unserialize</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="closure.construct.html">Closure::__construct</a></div>
 <div class="up"><a href="reserved.interfaces.html">预定义接口</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
